﻿using MediatR;
using System.CJL.API.Application.Command.FinishedProductsCommand;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.FinishedProductsCommandHanler
{
	/// <summary>
	/// 删除
	/// </summary>
	public class FinishedProductsDeleteCommandHandler : IRequestHandler<FinishedProductsDeleteCommand,int>
	{
		IFinishedProductRepositry _repositry;
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="repositry"></param>
        public FinishedProductsDeleteCommandHandler(IFinishedProductRepositry repositry)
        {
			_repositry = repositry;

		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="request"></param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>
		/// <exception cref="NotImplementedException"></exception>
		public async Task<int> Handle(FinishedProductsDeleteCommand request, CancellationToken cancellationToken)
		{
			var result = await _repositry.GetMondel(request.id);
			result.IsDelete = true;
			result.DelectName = "张三";
			result.DelectTime = DateTime.Now.ToUniversalTime();
			return await _repositry.UpdateAsync(result);
		}
	}
}
